import React, { Component } from 'react'
import {bindActionCreators} from 'redux';
import * as imgActions from '@/store/actions/img';
import {connect} from 'react-redux';

class BlockImage extends Component {
    render() {
        let imgUrl = this.props.imgUrl.replace('{0}','3');
        return (
            <div onClick={this.openDialog}>
                <img src={imgUrl} alt=""/>
            </div>
        )
    }

    openDialog = () => {
        console.log("dakai=====tanzhuang ")
        this.props.changeDialog(true);
        //获取对应的图片列表
        //如果已经存在类型的图片列表，不获取；
        this.props.imageID && this.props.getData(this.props.imageID);
        this.props.changeIndex(this.props.index);
    }
    
}

const stateMapToProps = (state) => {
    return {}
}

const dispatchMapToProps = (dispatch) => {
    return bindActionCreators(imgActions,dispatch);
}

export default connect(stateMapToProps,dispatchMapToProps)(BlockImage)
